package com.ibeeking.found.cop.cp.rest.controller.v1;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ibeeking.found.cop.cp.rest.service.ICopDepartmentService;
import com.ibeeking.found.cop.cp.rest.service.ICopEmployeeService;
import com.ibeeking.found.cop.service.common.bo.CopDepartmentUnionEmployeeBO;
import com.ibeeking.found.cop.service.common.query.CopDepartmentQuery;
import com.ibeeking.found.cop.service.common.query.CopEmployeePageQuery;
import com.ibeeking.found.cop.service.common.query.CopEmployeeQuery;
import com.ibeeking.found.cop.service.common.vo.CopDepartmentVO;
import com.ibeeking.found.cop.service.common.vo.CopEmployeeVO;
import com.ibeeking.nematos.constants.enums.OperateLogTypeEnum;
import com.ibeeking.nematos.log.annotation.Log;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassName contactListController
 * @Description
 * @Author ibeeking
 * @Date 2021-06-02 18:15
 **/
@RestController
@RequestMapping("/cp/contact/v1")
public class contactListController {

    @Resource
    private ICopDepartmentService copDepartmentServiceImpl;

    @Resource
    private ICopEmployeeService copEmployeeServiceImpl;

    /*
    ** 企业部门信息
    */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询部门列表树")
    @PostMapping(value = "/departmentTreeList/{parentId}")
    public List<CopDepartmentVO> departmentTreeList(@PathVariable("parentId") Long parentId) {
        List<CopDepartmentVO>  CopDepartmentVOS = copDepartmentServiceImpl.listByParentId(parentId);
        return CopDepartmentVOS;
    }
    /*
     ** 企业部门信息
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询部门+员工列表树")
    @PostMapping(value = "/listAllDepartmentUnionEmployee/{parentId}")
    public List<CopDepartmentUnionEmployeeBO> listAllDepartmentUnionEmployee(@PathVariable("parentId") Long parentId) {
        List<CopDepartmentUnionEmployeeBO>  CopDepartmentVOS = copDepartmentServiceImpl.listAllDepartmentUnionEmployee(parentId);
        return CopDepartmentVOS;
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询部门列表")
    @PostMapping(value = "/departmentList")
    public List<CopDepartmentVO> departmentList(@RequestBody CopDepartmentQuery query) {
        return copDepartmentServiceImpl.list(query);
    }

    /*
     ** 企业员工信息
     */
    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询部门员工列表")
    @PostMapping(value = "/employeelist")
    public List<CopEmployeeVO> employeelist(@RequestBody CopEmployeeQuery query) {
        return copEmployeeServiceImpl.list(query);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询部门员工分页列表")
    @PostMapping(value = "/employeePageList")
    public Page<CopEmployeeVO> employeePageList(@RequestBody CopEmployeePageQuery pageQuery) {
        return copEmployeeServiceImpl.pageList(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "查询部门员工分页列表(包括子部门)")
    @PostMapping(value = "/employeeWithSubPageList")
    public Page<CopEmployeeVO> employeeWithSubPageList(@RequestBody CopEmployeePageQuery pageQuery) {
        return copEmployeeServiceImpl.pageListWithSubDepartment(pageQuery);
    }

    @Log(logType = OperateLogTypeEnum.QUERY, describe = "部门员工信息查看")
    @GetMapping(value = "/view/{id}")
    public CopEmployeeVO view(@PathVariable("id") Long id) {
        return copEmployeeServiceImpl.view(id);
    }
}
